<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<title>欢迎加入云商姐姐社交电商</title>
<link rel="stylesheet" href="__PUBLIC__/wx/style/style.css" >
<link rel="stylesheet" href="__PUBLIC__/wx/style/demo.css" >
<link rel="stylesheet" href="__PUBLIC__/wx/style/LArea.css">
<script type="text/javascript" src="__PUBLIC__/wx/js/jquery-1.8.1.js"></script>
<script type="text/javascript" src="__PUBLIC__/wx/js/alert.js"></script>
<script type="text/javascript" src="__PUBLIC__/wx/js/confirm.js"></script>
<script>
var flag=0;
$(function(){
	$(".tanchu").hide();
    $("#radio3").click(function(){
		$(".tanchu").show();
		$('#c1').attr("checked",true);
		$('#c2').attr("checked",false);
		
		$('#c2').attr("disabled",true);
		
	});
	
	$("#r1").click(function(){
		$('#c2').attr("disabled",false);
	});
	$("#r2").click(function(){
		$('#c2').attr("disabled",false);
	});
	
	$(".tanchu p .span1").click(function(){
		$(".tanchu").hide(); 
	});

	var browser={
		versions:function(){
			var u = navigator.userAgent, 
				app = navigator.appVersion;
			return {
				trident: u.indexOf('Trident') > -1, //IE内核
				presto: u.indexOf('Presto') > -1, //opera内核
				webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
				gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
				mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
				ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
				android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
				iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
				iPad: u.indexOf('iPad') > -1, //是否iPad
				webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
				weixin: u.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
				qq: u.match(/\sQQ/i) == " qq" //是否QQ
			};
		}(),
		language:(navigator.browserLanguage || navigator.language).toLowerCase()
	}

	//判断是否移动端
	if(browser.versions.android){
		$("#demo1").click(function(){
			// alert("android");
			window.Yunoso.showAddressDialog();
		});
		// alert("android");
	}else{
		var area1 = new LArea();
		area1.init({
			'trigger': '#demo1', //触发选择控件的文本框，同时选择完毕后name属性输出到该位置
			'valueTo': '#value1', //选择完毕后id属性输出到该位置
			'keys': {
				id: 'id',
				name: 'name'
			}, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
			'type': 1, //数据源类型
			'data': LAreaData //数据源
		});
		area1.value=[1,13,3];//控制初始位置，注意：该方法并不会影响到input的value
	}
});
</script>
</head>

<body>
<div class="box">
<div class="wel">
<img src="__PUBLIC__/wx/images/jinru_01.jpg" class="img1">
<div class="input">
    <div class="div1">
    	<input type="text" name="username" id="username" placeholder="请填写真实的姓名">
    </div><!--div1-->
    <div class="div2">
   	    <input type="number" name="phone" id="phone">
    </div><!--div2-->
    <div class="div3">
        <input type="text" name="id_card" id="id_card">
    </div><!--div3-->
</div><!--input-->

<!-- 新增地址代码 -->
<div class="clear"></div>
  <div class="wel_dizhi">
  <div class="wel_div1">
   <div class="left"><img src="__PUBLIC__/wx/images/diqu.jpg"></div><!--left-->
   <div class="right">
   
      <div>
	    <div class="content-block">
		<img src="__PUBLIC__/wx/images/1.jpg" class="img"><input id="demo1" type="text" readonly="" placeholder="城市选择特效"  value="广东省深圳市南山区">
		<input id="value1" type="hidden" value="20,234,504">
        </div>
     </div>
<script src="__PUBLIC__/wx/js/LAreaData1.js"></script>
<script src="__PUBLIC__/wx/js/LAreaData2.js"></script>
<script src="__PUBLIC__/wx/js/LArea.js"></script>
<script>
/*var area1 = new LArea();
area1.init({
	'trigger': '#demo1', //触发选择控件的文本框，同时选择完毕后name属性输出到该位置
	'valueTo': '#value1', //选择完毕后id属性输出到该位置
	'keys': {
		id: 'id',
		name: 'name'
	}, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
	'type': 1, //数据源类型
	'data': LAreaData //数据源
});
area1.value=[1,13,3];//控制初始位置，注意：该方法并不会影响到input的value
var area2 = new LArea();
area2.init({
	'trigger': '#demo2',
	'valueTo': '#value2',
	'keys': {
		id: 'value',
		name: 'text'
	},
	'type': 2,
	'data': [provs_data, citys_data, dists_data]
});*/
</script>
   </div><!--right-->
</div><!--wel_div1-->
     <div class="clear"></div>
        <div class="textarea"><textarea id="addr" placeholder="请填写详细地址，不少于5个字"></textarea></div> 
  </div><!--wel_dizhi-->
<div class="clear"></div>




<div class="anniu">
<div class="opt">
				<input class="magic-radio" type="radio" name="radio" id="r1" value="5000" checked="checked">
				<label for="r1">一级</label>
			</div>
			<div class="opt">
				<input class="magic-radio" type="radio" name="radio" id="r2" value="2500" >
				<label for="r2">二级</label>
			</div>
            <div class="opt" id="radio3">
				<input class="magic-radio" type="radio" name="radio" id="r3" value="500">
				<label for="r3">三级</label>
			</div>
			
        </div>


</div><!--anniu-->
<div class="clear"></div>
<div class="dui">

<div class="col">
			<div class="opt ch1">
				<input class="magic-checkbox" type="radio" name="layout" id="c1" checked>
				<label for="c1">普通用户</label>
			</div>
			<div class="opt ch2">
				<input class="magic-checkbox" type="radio" name="layout" id="c2" >
				<label for="c2">使用峰会抵用券</label>
			</div>

			
 </div>

</div><!--dui-->
<div class="clear"></div>
<div class="tijiao">
<a href="javascript:;"><img src="__PUBLIC__/wx/images/jinru_09.jpg"></a>
</div>
<div class="clear"></div>
<div class="tanchu">
<p><img src="__PUBLIC__/wx/images/tanchu_03.jpg">
<span class="span1"></span>
</p>
</div><!--tanchu-->
</div><!--wel-->
</div><!--box-->
<script>
	$("#c2").click(function(){
		$.ajax({
			url:'__APP__/Home/Index/user_confirm',
			type:'post',
			data:{
				username:$("#username").val(),
				phone:$("#phone").val(),
				id_card:$("#id_card").val(),
			},
			success:function(data){
				if(data==1){
					flag=1;
				}else{
					alert(data);
					$("#c1").attr('checked','checked');
				}
			},
			eerror:function(){
				alert('服务器繁忙,请稍后再试!');
			}
		});
	});
	$(".tijiao").click(function(){
		var phone = $("#phone").val();
		var money = $("input:radio[name='radio']:checked").val();
		var username = $("#username").val();
		var id_card = $("#id_card").val();
		//0515+
		var area = $("#demo1").val();
		var addr = $("#addr").val();
		if(username==''){
			alert("用户名不能为空");
			return false;
		}
		if(phone==''){
			alert("手机号不能为空");
			return false;
		}
		if(!(/^1[34578]\d{9}$/.test(phone))){
			alert("请输入正确的手机号");
			return false;
		}
		if(id_card==''){
			alert("身份证不能为空");
			return false;
		}
		if(!(/^\d{17}(\d|x)$/i.test(id_card))){
			alert("请输入正确的身份证号码");
			return false;
		}
		if(addr == ''){
			alert("请填写详细地址!");
			return false;
		}
		//0515+
		var address = area+addr;
		// alert(address);
		if(flag){
			if(money>1000){
				money = money-999;
			}
			flag=0;
		}
		$.ajax({
			url:'__APP__/Home/Index/is_join',
			type:'post',
			data:{
				phone:phone,
				id_card:id_card,
			},
			success:function(data){
				if(data == 1){
					alert("用户已经注册");
				}else if(data == 3){
					zdconfirm('提示',"您的订单处于处理中状态已经超过24小时,是否取消该订单重新支付?", order_cancel);
					function order_cancel(){
						$.ajax({
							url:'__APP__/Home/Index/set_order_cancel',
							type:'post',
							data:{
								phone:phone,
								id_card:id_card,
							},
							success:function(data){
								if(data==1){
									// alert("订单已取消,请继续支付!");
									window.location.href="__APP__/Home/Pay/index?money="+money+'&phone='+phone+'&username='+username+'&id_card='+id_card+'&address='+address;
								}else{
									alert("订单取消失败,请重试!");
								}
							},
							error:function(){
								alert("服务器繁忙,请稍后再试");
							}
						});						
					}
				}else if(data == 4){
					alert("您的订单正在处理中,请耐心等待!");
				}else{
					//0515+
					window.location.href="__APP__/Home/Pay/index?money="+money+'&phone='+phone+'&username='+username+'&id_card='+id_card+'&address='+address;
				}
			},
			error:function(){
				alert("服务器繁忙,请稍后再试");
			}
		});
	});

	function setArea(a){
		$("#demo1").val(a);
	}
</script>
</body>
</html>
